package com.asialjim.wechat.official.cloud;

import com.asialjim.wechat.core.api.WeChatApiDefaultRes;
import com.asialjim.wechat.official.api.menu.AddConditionalMenuApiResponse;
import com.asialjim.wechat.official.api.menu.GetCurrentSelfMenuInfoApiResponse;
import com.asialjim.wechat.official.api.menu.GetMenuConfigApiResponse;
import com.asialjim.wechat.official.api.menu.TryMatchConditionalMenuApiResponse;
import com.asialjim.wechat.official.apiservice.OfficialMenuService;
import com.asialjim.wechat.official.menu.WeChatMenu;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <h1><em>ASIAL JIM JAVA DOC</em></h1><hr/>
 * <h2>CLASS DESCRIPTION <i>[ NAME: OfficialMenuCloud ]</i></h2><strong>
 * <p> official menu cloud
 * </strong><p><p><em>Copyright &copy; Asial Jim Co., LTD</em><hr/>
 *
 * @author Asial Jim &nbsp;&nbsp; <span>Email:<a href="mailto:asialjim@hotmail.com">asialjim@hotmail.com</a> &nbsp;&nbsp; <a href="asialjim@qq.com">asialjim@qq.com</a></span>
 * @version 1.0.0
 * @since 2021/3/30   &nbsp;&nbsp; JDK 8
 */
@RestController
@AllArgsConstructor
@RequestMapping("/we_chat/official/menu")
public class OfficialMenuCloud {
    private final OfficialMenuService officialMenuService;


    @PostMapping("/conditional/add")
    public AddConditionalMenuApiResponse addConditionalMenu(String ToUserName, @RequestBody WeChatMenu menu){
        return officialMenuService.addConditionalMenu(menu);
    }

    @PostMapping("/create")
    public WeChatApiDefaultRes createSelfMenu(String ToUserName, @RequestBody WeChatMenu menu){
        return officialMenuService.createSelfMenu(menu);
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: deleteConditionalMenu ]</i></h3>
     * delete conditional menu
     * @param menuId {@link String conditional menu id}
     * @return {@link WeChatApiDefaultRes api response}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/15 14:27
     */
    @GetMapping("/conditional/delete")
    public WeChatApiDefaultRes deleteConditionalMenu(String ToUserName, String menuId){
        return officialMenuService.deleteConditionalMenu(menuId);
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: getCurrentSelfMenuInfo ]</i></h3>
     * get current self menu info for we-chat official account
     * @return {@link GetCurrentSelfMenuInfoApiResponse self menu info}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/15 13:37
     */
    @GetMapping("/info")
    public GetCurrentSelfMenuInfoApiResponse getCurrentSelfMenuInfo(String ToUserName){
        return officialMenuService.getCurrentSelfMenuInfo();
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: getMenuConfig ]</i></h3>
     * get menu config
     * @return {@link GetMenuConfigApiResponse api response}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/15 14:31
     */
    @GetMapping("/config")
    public GetMenuConfigApiResponse getMenuConfig(String ToUserName){
        return officialMenuService.getMenuConfig();
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: tryMatchMenu ]</i></h3>
     * try match conditional menu
     * @param userId {@link String user id: we-chat user open id or user id}
     * @return {@link TryMatchConditionalMenuApiResponse api response}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/3/15 14:35
     */
    @GetMapping("/conditional/try")
    public TryMatchConditionalMenuApiResponse tryMatchMenu(String ToUserName,String userId){
        return officialMenuService.tryMatchMenu(userId);
    }
}
